package com.ruoyi.hospital.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.HospitalPatientData;
import com.ruoyi.hospital.service.IHospitalPatientDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医院患者数据Controller
 * 
 * @author ruoyi
 * @date 2025-04-24
 */
@RestController
@RequestMapping("/hospital/hospital_data")
public class HospitalPatientDataController extends BaseController
{
    @Autowired
    private IHospitalPatientDataService hospitalPatientDataService;

    /**
     * 查询医院患者数据列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospital_data:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalPatientData hospitalPatientData)
    {
        startPage();
        List<HospitalPatientData> list = hospitalPatientDataService.selectHospitalPatientDataList(hospitalPatientData);
        return getDataTable(list);
    }

    /**
     * 导出医院患者数据列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospital_data:export')")
    @Log(title = "医院患者数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalPatientData hospitalPatientData)
    {
        List<HospitalPatientData> list = hospitalPatientDataService.selectHospitalPatientDataList(hospitalPatientData);
        ExcelUtil<HospitalPatientData> util = new ExcelUtil<HospitalPatientData>(HospitalPatientData.class);
        util.exportExcel(response, list, "医院患者数据数据");
    }

    /**
     * 获取医院患者数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospital_data:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hospitalPatientDataService.selectHospitalPatientDataById(id));
    }

    /**
     * 新增医院患者数据
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospital_data:add')")
    @Log(title = "医院患者数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalPatientData hospitalPatientData)
    {
        return toAjax(hospitalPatientDataService.insertHospitalPatientData(hospitalPatientData));
    }

    /**
     * 修改医院患者数据
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospital_data:edit')")
    @Log(title = "医院患者数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalPatientData hospitalPatientData)
    {
        return toAjax(hospitalPatientDataService.updateHospitalPatientData(hospitalPatientData));
    }

    /**
     * 删除医院患者数据
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospital_data:remove')")
    @Log(title = "医院患者数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hospitalPatientDataService.deleteHospitalPatientDataByIds(ids));
    }
}
